#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <netdb.h>

#define BUF_SIZ 4096


int handle_client(const int sock)
{
    char buffer[BUF_SIZ];
    int bytes;

    
    bytes = recv(sock, buffer, sizeof(buffer), 0);
 
    send(sock, buffer, strlen(buffer), 0);
	printf("client 1! %s\n",buffer);
    return 0;
}



int main(int argc, char *argv[])
{
    struct hostent *host;
    struct sockaddr_in addr;
    int s,bytes;
  
    
    

    s = socket(PF_INET, SOCK_STREAM, 0);
    if (s == -1)
    {
        perror("socket() failed");
        return 3;
    }

                
  addr.sin_addr.s_addr = inet_addr("127.0.0.1"); 
  addr.sin_port=htons(1234); 
  addr.sin_family = AF_INET; 
 
 if (connect(s, (struct sockaddr*)&addr, sizeof(addr)) == -1)
   {
     perror("connect() failed");
     return 4;
   }
 printf("verbindung steht\n");
 for(;;)   
   {handle_client(s);
 
   }
 close(s);
 
 return 0;
    }
